<?php if($this->type=="-1") {?> 
	<center><?php echo $this->textError3;?></center>
<?php } else if ($this->error==2) {?>
<center><?php echo $this->textError2;?></center>
<?php } else{ ?>
<h2><?php echo $this->textName ?></h2>
<table>
<tr>
	<td>Default </td>
	<td><input type = "text"  name="name[default]" id="name[default]" size="32" maxlength="11"  value=""></input></td>
</tr>
<?php if(isset($this->languages) && count($this->languages) > 0 ){?>
	<?php foreach ($this->languages as $lang){?>
		<tr>
			<td><?php echo $lang['name'];?> </td>
			<td><input type = "text"  name="name[<?php echo $lang['name'];?>]" id="name[<?php echo $lang['name'];?>]" size="32" maxlength="11"  value=""></input></td>		
		</tr>
	<?php }?>
<?php }?>
</table>
<input type = "hidden"  name="catetype" id="catetype" size="32" maxlength="45"  value="<?php echo $this->type; ?>" />
<input type = "hidden"  name="parent_id" id="parent_id" size="32" maxlength="45"  value="<?php echo $this->parent_id; ?>" >
<div style="clear:both;	float:left;	width:100%;">
	<input type="button" style="float: right; margin: 10px; width: 60px;height: 30px; color:white; border: none; background-image: url('../images/btn_short.png');" value="<?php echo $this->textSave ?>" onclick = "Add()">
</div>

<script type="text/javascript">
function Add()
{ 
	
	var _nameDefault= document.getElementById("name[default]").value;
	var _name = '';
<?php if(isset($this->languages) && count($this->languages) > 0 ){?>
<?php foreach ($this->languages as $lang){?>
<?php echo ('_name += "&name'.$lang['name'].'=" + document.getElementById("name['.$lang['name'].']").value;');?>
<?php }?>
<?php }?>
	var _catetype= document.getElementById("catetype").value;
	var _parent= document.getElementById("parent_id").value;
	
	if (window.XMLHttpRequest)
	{// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp=new XMLHttpRequest();
	}
	else
	{// code for IE6, IE5
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlhttp.onreadystatechange = function()
	{	
		if (xmlhttp.readyState==4 && xmlhttp.status==200)
		{
			if(xmlhttp.responseText == "-1")
			{
				alert(<?php echo "'".$this->textError9."'";?>);
			}
			else if(xmlhttp.responseText == "-2")
			{
				alert(<?php echo "'".$this->textError10."'";?>);
			}
			else if(xmlhttp.responseText == "-3")
			{
				alert(<?php echo "'".$this->textError11."'";?>);
			}
			else if(xmlhttp.responseText == "-4")
			{
				alert(<?php echo "'".$this->textError12."'";?>);
			}
			else if(xmlhttp.responseText == "-5")
			{
				alert(<?php echo "'".$this->textError12."'";?>);
			}
			else if(xmlhttp.responseText == "-6")
			{
				alert(<?php echo "'".$this->textError14."'";?>);
			}
			else if(xmlhttp.responseText == "-10")
			{
				alert(<?php echo "'".$this->textError2."'";?>);
			}
			else
			{	
				window.parent.$.prettyPhoto.close();
				window.top.location.reload();
			}
		}	
	};
	var url = "/category/clickchange/addlcategory?nameDefault="+_nameDefault+_name+"&catetype="+_catetype+"&parent="+_parent;
	xmlhttp.open("GET",url,true);	
	xmlhttp.send();
	return false;
}
</script>
<?php } ?>